<?php
// ============================================================
// SPL check
in_array('SPL', get_loaded_extensions(), true) || die('This app needs PHP SPL extension');
// ============================================================
// Application env definition (production, development, ...) defini dans le .htaccess
defined('APPLICATION_ENV')
	|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

/**
 * @param   String
 * @return  void
 */
function Tv_Arte_autoload($name)
{
	$tokens = explode('_', $name);
	$fileName = array_pop($tokens) . '.php';
	$path = '';
	foreach ($tokens as $key => $value) {
		$path .= $value . '/';
	}
 	if (file_exists($file = '../' . $path . $fileName)) {
 	    require_once($file);
 	}
}
spl_autoload_register('Tv_Arte_autoload');

/**
 * REWRITE RULES
 *
 * 		/Tv_Arte_HeaderIncludeJsonp_([0-9a-z]+)_([a-z]{0,2}).js
 * 		=>
 * 		http://php4.arte.tv/header-include/assets/js/Tv_Arte_HeaderInclude.js?id=$1&lang=$2 	[P]
 *
 *      /Tv_Arte_CacheableIFrame_([0-9a-z]+)_([a-z]{0,2}).js
 *      =>
 *      http://php4.arte.tv/header-include/assets/js/Tv_Arte_CacheableIFrame.js?id=$1&lang=$2
 *
 */
